/*
 * @Description: 开关组件
 * @Author: Rfan
 * @Date: 2022-08-23 20:24:09
 * @LastEditTime: 2023-02-01 10:20:56
 */

import { Switch } from 'antd';

const JPSwitch = ({
  checked,
  activeValue = true,
  inactiveValue = false,
  onChange,
  ...rest
}: any) => {
  const transformedValue = checked === activeValue;
  const transformedOnChange = (value: any) => {
    onChange(value ? activeValue : inactiveValue);
  };
  return <Switch {...rest} checked={transformedValue} onChange={transformedOnChange} />;
};

export default JPSwitch;
